<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let arr = [1, 2, 3, 4, 5, 6]
    const res = arr.some(item => {
      return item === 5
    })
    console.log(res);
    function selfsome(arr, cb) {
      let state=null
      // 先遍历数组每一项
      for (let i = 0; i < arr.length; i++) {
        // 将数组每一项传给函数 且得到结果
        let res = cb(arr[i])
        // 如果值传进来 只要有一次为true那么就直接返回true
        if (res) {
        return state=true
        }else{ // 
          // 每次值遍历 返回的是false那么就直接false  直到全部遍历完
          state=false
        }
      }
      return state
    }
    const arr2 = selfsome(arr, (item) => {
      return item === 5
    })
    console.log(arr2);
  </script>
</body>

</html>